package com.ydd.controller.user;


import com.ydd.result.Result;
import org.springframework.web.bind.annotation.GetMapping;
import com.ydd.dto.AdvimgDTO;
import com.ydd.entity.Advimg;
import com.ydd.result.Result;
import com.ydd.service.IAdvimgService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ydd.result.Result;
import org.springframework.web.bind.annotation.GetMapping;
import com.ydd.result.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hgz
 * @since 2023-05-30
 */
@RestController
@Slf4j
@RequestMapping("/admin/ydd_advimg")
public class AdvimgController {
    @Autowired
    private IAdvimgService iAdvimgService;

    @GetMapping("/rowInfo")
    public Result<Advimg> rowInfo(@RequestParam Integer id){
        log.info("根据id回显数据：{}",id);
        Advimg advimg = iAdvimgService.rowInfo(id);
        return Result.success(advimg);
    }
    @GetMapping("/list")
    public Result<Map<String,Object>> list(AdvimgDTO advimgDTO){

        Map<String,Object> map = iAdvimgService.selectPage(advimgDTO);

        return Result.success(map);
    }
    @PostMapping("/update")
    public Result<Advimg> upd(@RequestBody Advimg advimg){

        log.info("广告图修改接口：{}",advimg);

        iAdvimgService.upd(advimg);

        return Result.success();
    }
    @GetMapping("/del")
    public Result del(@RequestParam Integer id){

        log.info("广告位删除接口：{}",id);
        iAdvimgService.del(id);

        return Result.success();
    }
    @PostMapping("/add")
    public Result add(@RequestBody Advimg advimg){

        iAdvimgService.add(advimg);
        return Result.success();
    }


}
